<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="text" placeholder="请输入需要查找的id、商品名称、价格、库存、供应商" name="keyword">
        <input type="button" value="查找" onclick="query()">
        <input type="button" value="添加" onclick="add()">
    </div>
    <table>
        <tr>
            <td>
                id
            </td>
            <td>
                标题
            </td>
            <td>
                摘要
            </td>
            <td>
                内容
            </td>
            <td>
                分类
            </td>
            <td>
                作者
            </td>
            <td>
                发表时间
            </td>
            <td>
                操作
            </td>
            
        </tr>
    </table>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./js/init.js"></script>
    <script src="./js/api.js"></script>
<script>
    function update(id) {
    location.href = './addOrEdit.html?id=' + id;
}
function del(id) {
    delProductById(id).then(data => {
        if (data.code === 1000) {
            let id = data.data.id;
            $(`[key=${id}]`).remove();
        } else {
            alert(data.msg);
        }
    })
}
function query(){
    let keyword=$('[name=keyword]').val();
    getListWithKeyword(keyword);
}
</script>
</body>
</html>